package cate.common.table.activity.powerdash.sheet;

import cate.common.table.ESheet;
import cate.common.table.activity.limitshopactivity.row.LimitShopActivityItemRow;
import cate.common.table.activity.powerdash.row.PowerDashRow;

import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liuyunke
 * @program: cate-game
 * @create
 * @description:
 */
public class PowerDashSheet extends ESheet<PowerDashRow> {
    @Override
    public String getSheetName() {
        return "任务目标";
    }

    public PowerDashRow getRowByPower(long power) {
        PowerDashRow row = null;
        for (PowerDashRow dashRow : list) {
            if (dashRow.lowest <= power && dashRow.highest >= power) {
                row = dashRow;
            }
        }
        PowerDashRow lastRow = list.get(list.size() - 1);
        if (row == null && power > lastRow.highest) {
            row = lastRow;
        }
        return row;
    }

    public List<PowerDashRow> getItems(int group) {
        return getList().stream().filter(e -> e.group == group).collect(Collectors.toList());
    }
}
